import React, { Component } from 'react';
import ListItem from '../ListItem';
import { list } from '../../../mock/CommentList';

export default class List extends Component {
  constructor() {
    super();

    this.state ={
      list: []
    };
  }

  componentDidMount() {
    this.getList();
  }

  getList = () => {
    // api
    this.setState({
      list: list
    });
  }

  render() {
    return (
      <div className='list'>
        {
          this.state.list.map((item, index) => {
            return <ListItem key={ index } index={ index } content={ item } refresh={ this.getList } ></ListItem>
          })
        }
      </div>
    )
  }
};
